$('#concept_time_search').linkbutton({  //查询按钮
    iconCls: "icon-search"
});

$(function () {


    $('#concept_time_search').click(function () {
        concept_stock_info.search()
    });


    var concept_stock_info = {                     //obj对象
        search: function () {
            $('#concept_time_table').datagrid('load', $("#concept_time_form").parseForm());
        }
    };
    $('#concept_time_table').datagrid({
        // width: 1500,                 //设置宽度
        url: '/concept/ranking/time',       //远程加载数据地址
        title: '行业排行分时',           //面板属性，添加标题
        iconCls: 'icon-search',     //添加图标
        method: 'get',
        queryParams: $("#concept_time_form").parseForm(),
        selectOnCheck: true,
        remoteSort: true,
        view: groupview,
        groupField: 'time_interval',
        groupFormatter: function (value, rows) {
            return value + ' - ' + rows.length + ' Item(s)';
        },
        columns: [[                 //设置要显示表格数据
            {
                field: 'concept_name',
                title: '概念名称',
                formatter: formatConcept
            },
            {
                field: 'concept_code',
                title: '概念编码'
            }
            , {
                field: 'now_price',
                title: '当前价'
            }
            , {
                field: 'volume_ratio',
                title: '量比'
            }
            , {
                field: 'pctChg',
                title: '涨跌幅'
            }
            , {
                field: 'turn',
                title: '换手率'
            }
            , {
                field: 'rising_nums',
                title: '上涨家数'
            }
            , {
                field: 'decliner_nums',
                title: '下跌家数'
            }
            , {
                field: 'leading_stock_name',
                title: '领涨股票名称'
            }
            , {
                field: 'main_net_inflow',
                title: '资金净流入',
                sortable: true
            }
            , {
                field: 'time_interval',
                title: '时间区间'
            }
            , {
                field: 'create_time',
                title: '创建时间',
                formatter:dateFormatter
            }

        ]],
        pagination: true,         //组件底部显示分页工具栏
        pageNumber: 1,             //设置分页时初始化页码
        pageSize: 100,               //设置分页时设置每页多少条
        pageList: [100, 200, 300, 500],          //设置可选每页显示条数
        // fitColumns: true,         //设置表格自适应
        // {#scrollbarSize: 0,          //滚动条所占的宽度或高度。默认为18。#}
        rownumbers: true,
        toolbar: '#concept_time_toolbar',
        onBeforeLoad: function (param) {
            var firstLoad = $(this).attr("firstLoad");
            if (firstLoad == "false" || typeof (firstLoad) == "undefined") {
                $(this).attr("firstLoad", "true");
                return false;
            }
            return true;
        }
    });


    function formatConcept(val, row, index) {
        var href_url = 'http://quote.eastmoney.com/bk/90.' + row.concept_code + '.html'
        return '<a href="' + href_url + '" target="_blank">' + row.concept_name + '</a>';
    }

});

